<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>酷妈妈商城</title>
</head>
<body>
	<h1>订单列表</h1>
	<c:if test="${empty orders}">
		<h1>还没有添加任何订单！</h1>
	</c:if>
	<c:if test="${not empty orders}">
		<c:forEach var="order" items="${orders}">
			订单编号： ${order.id } 下单用户：${order.user.username} 下单时间：${order.ordertime}<br />
			金额：${order.totalmoney} 状态：${order.state=="0"?"未支付":"已支付" } <br>
			<p>收货人信息：${order.receiverinfo}</p>  
			<c:if test="${order.state==0 and sessionScope.loginUser.role=='user'}">
				<a href="<%=basePath %>delOrder?id=${order.id}">删除订单</a>
				<form action="<%=basePath %>pay.jsp" method="post" style="display: inline;">
				 <input type="hidden" name="totalmoney" value="${order.totalmoney}">
				 <input type="hidden" name="order_id" value="${order.id}">
				 <input type="submit" value="马上支付">
				</form>
			</c:if>
			<h3>订单项</h3>
			<table border="1px">
				<tr>
					<th>编号：</th>
					<th>产品名称：</th>
					<th>单价：</th>
					<th>购买数量：</th>
				</tr>
				<c:forEach var="item" items="${order.orderItems}">
					<tr>
						<td>${item.product_id}</td>
						<td>${item.product.name}</td>
						<td>${item.product.price}</td>
						<td>${item.buynum}</td>
					</tr>
				</c:forEach>
			</table>
			<h1></h1>
			<hr/>
		</c:forEach>
	</c:if>
	
</body>
</html>